{include file="../common/header"}
<!--页面主要内容-->
<main class="lyear-layout-content">
    <div class="container-fluid p-t-15">
        <div class="row">
            <div class="col-lg-12">
                <div class="card">
                    <div class="card-toolbar d-flex flex-column flex-md-row">
                        <div class="toolbar-btn-action">
                            <a class="btn btn-danger" onclick="delshopordertotal()"><i class="mdi mdi-window-close"></i> 删除</a>
                        </div>
                    </div>
                    <div class="card-body">

                        <div class="table-responsive">
                            <table class="table table-bordered" id="search_result">
                                <thead>
                                <tr>
                                    <th>
                                        <div class="custom-control custom-checkbox">
                                            <input type="checkbox" class="custom-control-input" id="check-all">
                                            <label class="custom-control-label" for="check-all"></label>
                                        </div>
                                    </th>
                                    <th>序号</th>
                                    <th>商品名称</th>
                                    <th>商品类型</th>
                                    <th>购买用户</th>
                                    <th>应用名称</th>
                                    <th>创建时间</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                {volist name="list" id="shoporder" key="u"}
                                <tr id="{$shoporder.id}">
                                    <td>
                                        <div class="custom-control custom-checkbox">
                                            <input type="checkbox" class="custom-control-input ids" name="ids[]" value="{$shoporder.id}" id='ids{$shoporder.id}'>
                                            <label class="custom-control-label" for="ids{$shoporder.id}"></label>
                                        </div>
                                    </td>
                                    <td>{$u}</td>
                                    <td>{$shoporder.shopname}</td>
                                    <td>{$shoporder.shoptype}</td>
                                    <td>{$shoporder.username}</td>
                                    <td>{$shoporder.appname}</td>
                                    <td>{$shoporder.creat_time}</td>
                                    <td>
                                        <div class="btn-group">
                                            <a class="btn btn-xs btn-default id ajax-get confirm" dataid = "{$shoporder.id}" onclick="deleteshoporder(this)" title="" data-toggle="tooltip" data-original-title="删除"><i class="mdi mdi-window-close"></i></a>
                                        </div>
                                    </td>
                                </tr>
                                {/volist}
                                </tbody>
                            </table>
                        </div>
                        {$page|raw}
                    </div>
                </div>
            </div>
        </div>
    </div>
</main>
<!--End 页面主要内容-->
</div>
</div>
{include file="../common/footer"}
<script>
    function getnumber() {
        var date = $("input[name = 'ids[]']");
        var str = [];
        for(let i = 0;i < date.length;i++) {
            if (date[i].checked == true) {
                str.push(date[i].value);
            }
        }
        return str;
    }



    function deleteshoporder(obj){
        var l = $('body').lyearloading({
            opacity: 0.2,
            spinnerSize: 'lg',
            spinnerText: '后台处理中，请稍后...',
            textColorClass: 'text-info',
            spinnerColorClass: 'text-info'
        });
        var id = $(obj).attr("dataid");
        $.ajax({
            type: "POST",
            url: "{:url('/admin/shop/delshoporder')}",
            data: {
                id: id,
            },
            //dataType: "json",
            success: function (data) {
                setTimeout(function() {
                    l.destroy();
                }, 1e3)
                if (data.code == 200) {
                    $.notify({
                        message: data.msg
                    },{
                        placement: {
                            from: "top",
                            align: "center"
                        },
                        type: 'success'
                    });
                    setTimeout("location.reload();", 2000);
                } else {
                    $.notify({
                        message: data.msg
                    },{
                        placement: {
                            from: "top",
                            align: "center"
                        },
                        // settings
                        type: 'danger'
                    });
                }
            },
        });
    }

    function delshopordertotal(){
        var getnum = getnumber().toString();
        console.log(getnum);
        if (getnum.length == 0){
            $.notify({
                message: "你还没有选择呢",
            },{
                placement: {
                    from: "top",
                    align: "center"
                },
                type: 'success'
            });
        }else{
            var l = $('body').lyearloading({
                opacity: 0.2,
                spinnerSize: 'lg',
                spinnerText: '后台处理中，请稍后...',
                textColorClass: 'text-info',
                spinnerColorClass: 'text-info'
            });
            $.ajax({
                type: "POST",
                url: "{:url('/admin/shop/delshoporder')}",
                data: {
                    id: getnum
                },
                dataType: "json",
                success: function (data) {
                    setTimeout(function() {
                        l.destroy();
                    }, 1e3)
                    if (data.code == 200) {
                        $.notify({
                            message: data.msg
                        },{
                            placement: {
                                from: "top",
                                align: "center"
                            },
                            type: 'success'
                        });
                        setTimeout("location.reload();", 2000);
                    } else {
                        $.notify({
                            message: data.msg
                        },{
                            placement: {
                                from: "top",
                                align: "center"
                            },
                            // settings
                            type: 'danger'
                        });
                    }
                },
            });
        }
    }


</script>

</body>

</html>
